#pragma once
// ==============================================================================
//  排行榜管理器
// ------------------------------------------------------------------------------

#include <unordered_map>
#include <queue>

#include "../share/user_define.h"
#include "RankingList.h"


class RankData;
class Player;

// ------------------------------------------------------------------------------
//	排行榜管理类模板定义
class RankingListBufferMgr
{
public:
	//---------------------------------------------------------------------------
	RankingListBufferMgr();
	//---------------------------------------------------------------------------
	RankingListBufferMgr(uint32_t max_count);
	//---------------------------------------------------------------------------
	~RankingListBufferMgr();

public:
	//---------------------------------------------------------------------------
	bool RegistRankListData(uint32_t runTimeCount);

	//---------------------------------------------------------------------------
	void UpdateRankListDataAtRegular(uint32_t typeIdx, std::string& rData
		, uint32_t start, uint32_t count);

	//---------------------------------------------------------------------------
	void GetRankListMessageDataByErea(uint32_t typeId
		, uint32_t minRanking, uint32_t maxRanking, Json::Value& jv);
	//---------------------------------------------------------------------------
	bool DeleteRankListData(uint32_t rankType);

public:
	//---------------------------------------------------------------------------
	uint32_t GetPlayerRankingByRankType(uint32_t typeId, uint32_t playerId);
	//---------------------------------------------------------------------------
	void SetUpdateStateByRankType(uint32_t typeId, uint32_t state);
	//---------------------------------------------------------------------------
	void AddMemberToTimingListByRankType(uint32_t typeId, std::string strPlayerInfo);

public:
	uint32_t GetFreePos();
	bool UnregistAgent(uint32_t rankType);

public:
	std::unordered_map<uint32_t, uint32_t> m_map_type_idx;
	std::queue<uint32_t> m_free_pos;
	std::vector<RankingList> m_buffer;
	uint32_t m_max_count;
};